#include "mainwindow.h"


void DriverThread::run()
{
    // 防止重复定义
    if(!speed_talker_node_cpp)
    {
        speed_talker_node_cpp = rclcpp::Node::make_shared("speed_talker");
    }
    if(!speed_pub_)
    {
        speed_pub_ = speed_talker_node_cpp->create_publisher<std_msgs::msg::Int32>("speed_true", 10);
    }
    auto input_speed_data = std_msgs::msg::Int32();
    // 整条的百分百，加float，否则会只有0和1
    speedValuePercent = ((float)currentDriverValue) / 100;
    currentDriverValue = std::round(speedValuePercent * 12 * 180 * 101 * 100 / 360 / 10 /3.14);
    input_speed_data.data = currentDriverValue;
    speed_pub_->publish(input_speed_data);

}


